/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import core.Graph;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 *
 * @author Alexey Chirkov
 */
public class Server {

    private static Registry registry;
    private static int port = 1099;

    public static void main(String[] args) throws AlreadyBoundException {
        try {
            //-Djava.rmi.server.codebase
            System.out.println("Создаем объект, реализующий сервис...");
            Graph service = new GraphImpl();
            Graph stub = (Graph) UnicastRemoteObject.exportObject(service, 0);
            Registry registry = LocateRegistry.createRegistry(port);
            registry.bind("Graph", stub);
            System.err.println("Server ready");

        } catch (RemoteException e) {
            System.out.println("Error");
            e.printStackTrace();
        }
    }
}
